﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;

#if !SILVERLIGHT
namespace UIT.WPF.Converters
#else
namespace UIT.Silverlight.Converters
#endif
{
    class ColorConverter : IValueConverter
    {
        public static System.Windows.Media.Color Convert(Style.Color color)
        {
            return System.Windows.Media.Color.FromArgb(color.Alpha, color.Red, color.Green, color.Blue);
        }


        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (targetType == typeof(System.Windows.Media.Color))
                return Convert((Style.Color)value);
            else if (targetType == typeof(System.Windows.Media.Brush))
                return new SolidColorBrush(Convert((Style.Color)value));
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
